package com.twu.biblioteca.model;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * User: Aaron Edwards
 * Date: 9/10/13
 * Time: 2:32 PM
 * Email: aedwards@thoughtworks.com
 */
public class Movie {
    private String movieTitle;
    private String director;
    private int year;
    //A rating of 0 corrisponds to N/A (not rated)
    private int rating;


    public Movie(String movieTitle, String director, int year, int rating) {
        this.movieTitle = movieTitle;
        this.director = director;
        this.year = year;
        this.rating = rating;
    }


    public String getTitle() {
        return movieTitle;
    }

    public String getDirector() {
        return director;
    }

    public int getYear() {
        return year;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }

    public String getRatingString() {
        if (rating <= 0) {
            return "N/A";
        } else {
            char[] stars = new char[rating];
            Arrays.fill(stars, '*');
            return new String(stars);
        }
    }

    public String getDisplayString() {
        return String.format("%s\t%s\t%d\t%s", movieTitle, director, year, getRatingString());
    }
}
